/**
 * 优惠券页面
 * author:zhushy
 * date:2016年3月15日16:30:42
 */
;
define(function(require, exports, module) {
	var wechat = require("wechat");
	var template = require("template");
	var coupon = {
		data: {},
		/**
		 * bindEvent 页面事件
		 */
		bindEvent: function() {
			//返回
			$("#return_coupon").unbind().on("click", function() {
				window.location.href = "#home";
			});
		},
		/**
		 * 进行页面路由监听配置
		 * 
		 */
		bindRout: function() {
			//首页监听路由
			Path.map("#home").to(function() {
				//返回首页
				common.loadPage({
					pageUrl: "html/index.html",
					reload: false,
					from: "left"
				});
			});
			Path.listen();
		},
		/**
		 * 页面数据加载
		 */
		initData: function() {
			
			/*var param = {
				"openId":window.localStorage.getItem("openId")	
			};
			common.loadData({
				url: "/getWxUserInfo",
				param: param,
				successCallBack: index.getWxUserInfoCallBack, //回调函数
				dataSource: "getWxUserInfo"
			});*/

			//iscroll滚动加入
			var iscroll = require("iscroll");
			common.initIscroll({
				container: "iscrollContent_coupon",
				showScrollBar: false
			});

		},
		//callback function
		getWxUserInfoCallBack: function(json) {
			console.log("调用后台ajax返回值为：" + JSON.stringify(json));
			if(json.status == "0") {
				index.data = json;

				//var html1 = template('cardtemplate', index.data);
				//document.getElementById('card').innerHTML = html1;
				//var html2 = template('datetemplate', index.data);
				//document.getElementById('main_info').innerHTML = html2;
			} else {
				common.showTip({
					content:json.message
				});
			}
		},
		/**
		 * each page init mothed
		 */
		initialize: function() {
			//动态加载数据
			this.initData();
			//事件绑定
			this.bindEvent();
			//路由绑定
			this.bindRout();
		}
	};

	module.exports = coupon;
});